package es.cea.tareas;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import es.cea.tareas.model.Tarea;

/**
 * Servlet implementation class ListaTareasServlet
 */
public class ListaTareasServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	Log logger=LogFactory.getLog(this.getClass());



	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Object attribute = request.getSession().getServletContext().getAttribute("tareas");
		List<Tarea> tareas=(List<Tarea>) attribute;
		PrintWriter w = response.getWriter();
		w.print("<h1>LISTA DE TAREAS</h1>");
		for(Tarea tarea:tareas) {
			w.print("<ul>"+
					tarea.titulo+" "+
					"<a href='./editaTarea?idTarea="+tarea.id+"'>editar</a>" +
					"</ul>");
		}
		
		
	}



	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
